﻿


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;



public partial class VER3 : System.Data.Linq.DataContext
{
	
	private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
	
  #region Extensibility Method Definitions
  partial void OnCreated();
  partial void InsertPost(Post instance);
  partial void UpdatePost(Post instance);
  partial void DeletePost(Post instance);
  partial void InsertSubForum(SubForum instance);
  partial void UpdateSubForum(SubForum instance);
  partial void DeleteSubForum(SubForum instance);
  partial void InsertThread(Thread instance);
  partial void UpdateThread(Thread instance);
  partial void DeleteThread(Thread instance);
  #endregion
	
	public VER3(string connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public VER3(System.Data.IDbConnection connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public VER3(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public VER3(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public System.Data.Linq.Table<Post> Posts
	{
		get
		{
			return this.GetTable<Post>();
		}
	}
	
	public System.Data.Linq.Table<SubForum> SubForums
	{
		get
		{
			return this.GetTable<SubForum>();
		}
	}
	
	public System.Data.Linq.Table<Thread> Threads
	{
		get
		{
			return this.GetTable<Thread>();
		}
	}
}

[Table(Name="dbo.Posts")]
public partial class Post : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private int _PostID;
	
	private string _Description;
	
	private System.Nullable<int> @__ThreadID;
	
	private string _Title;
	
	private string _Body;
	
	private string @__ClientID;
	
	private System.Nullable<System.DateTime> _Time;
	
	private EntityRef<Thread> _Thread;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnPostIDChanging(int value);
    partial void OnPostIDChanged();
    partial void OnDescriptionChanging(string value);
    partial void OnDescriptionChanged();
    partial void On_ThreadIDChanging(System.Nullable<int> value);
    partial void On_ThreadIDChanged();
    partial void OnTitleChanging(string value);
    partial void OnTitleChanged();
    partial void OnBodyChanging(string value);
    partial void OnBodyChanged();
    partial void On_ClientIDChanging(string value);
    partial void On_ClientIDChanged();
    partial void OnTimeChanging(System.Nullable<System.DateTime> value);
    partial void OnTimeChanged();
    #endregion
	
	public Post()
	{
		this._Thread = default(EntityRef<Thread>);
		OnCreated();
	}
	
	[Column(Storage="_PostID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	public int PostID
	{
		get
		{
			return this._PostID;
		}
		set
		{
			if ((this._PostID != value))
			{
				this.OnPostIDChanging(value);
				this.SendPropertyChanging();
				this._PostID = value;
				this.SendPropertyChanged("PostID");
				this.OnPostIDChanged();
			}
		}
	}
	
	[Column(Storage="_Description", DbType="NVarChar(50)")]
	public string Description
	{
		get
		{
			return this._Description;
		}
		set
		{
			if ((this._Description != value))
			{
				this.OnDescriptionChanging(value);
				this.SendPropertyChanging();
				this._Description = value;
				this.SendPropertyChanged("Description");
				this.OnDescriptionChanged();
			}
		}
	}
	
	[Column(Storage="__ThreadID", DbType="Int")]
	public System.Nullable<int> _ThreadID
	{
		get
		{
			return this.@__ThreadID;
		}
		set
		{
			if ((this.@__ThreadID != value))
			{
				if (this._Thread.HasLoadedOrAssignedValue)
				{
					throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
				}
				this.On_ThreadIDChanging(value);
				this.SendPropertyChanging();
				this.@__ThreadID = value;
				this.SendPropertyChanged("_ThreadID");
				this.On_ThreadIDChanged();
			}
		}
	}
	
	[Column(Storage="_Title", DbType="NVarChar(50)")]
	public string Title
	{
		get
		{
			return this._Title;
		}
		set
		{
			if ((this._Title != value))
			{
				this.OnTitleChanging(value);
				this.SendPropertyChanging();
				this._Title = value;
				this.SendPropertyChanged("Title");
				this.OnTitleChanged();
			}
		}
	}
	
	[Column(Storage="_Body", DbType="NVarChar(50)")]
	public string Body
	{
		get
		{
			return this._Body;
		}
		set
		{
			if ((this._Body != value))
			{
				this.OnBodyChanging(value);
				this.SendPropertyChanging();
				this._Body = value;
				this.SendPropertyChanged("Body");
				this.OnBodyChanged();
			}
		}
	}
	
	[Column(Storage="__ClientID", DbType="NVarChar(50)")]
	public string _ClientID
	{
		get
		{
			return this.@__ClientID;
		}
		set
		{
			if ((this.@__ClientID != value))
			{
				this.On_ClientIDChanging(value);
				this.SendPropertyChanging();
				this.@__ClientID = value;
				this.SendPropertyChanged("_ClientID");
				this.On_ClientIDChanged();
			}
		}
	}
	
	[Column(Storage="_Time", DbType="DateTime")]
	public System.Nullable<System.DateTime> Time
	{
		get
		{
			return this._Time;
		}
		set
		{
			if ((this._Time != value))
			{
				this.OnTimeChanging(value);
				this.SendPropertyChanging();
				this._Time = value;
				this.SendPropertyChanged("Time");
				this.OnTimeChanged();
			}
		}
	}
	
	[Association(Name="FK_Posts_Threads", Storage="_Thread", ThisKey="_ThreadID", OtherKey="ThreadID", IsForeignKey=true)]
	public Thread Thread
	{
		get
		{
			return this._Thread.Entity;
		}
		set
		{
			Thread previousValue = this._Thread.Entity;
			if (((previousValue != value) 
						|| (this._Thread.HasLoadedOrAssignedValue == false)))
			{
				this.SendPropertyChanging();
				if ((previousValue != null))
				{
					this._Thread.Entity = null;
					previousValue.Posts.Remove(this);
				}
				this._Thread.Entity = value;
				if ((value != null))
				{
					value.Posts.Add(this);
					this.@__ThreadID = value.ThreadID;
				}
				else
				{
					this.@__ThreadID = default(Nullable<int>);
				}
				this.SendPropertyChanged("Thread");
			}
		}
	}
	
	public event PropertyChangingEventHandler PropertyChanging;
	
	public event PropertyChangedEventHandler PropertyChanged;
	
	protected virtual void SendPropertyChanging()
	{
		if ((this.PropertyChanging != null))
		{
			this.PropertyChanging(this, emptyChangingEventArgs);
		}
	}
	
	protected virtual void SendPropertyChanged(String propertyName)
	{
		if ((this.PropertyChanged != null))
		{
			this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}
	}
}

[Table(Name="dbo.SubForums")]
public partial class SubForum : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private int _SubForumID;
	
	private string _Description;
	
	private string _Title;
	
	private string _Moderator;
	
	private System.Nullable<System.DateTime> _DateTime;
	
	private EntitySet<Thread> _Threads;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnSubForumIDChanging(int value);
    partial void OnSubForumIDChanged();
    partial void OnDescriptionChanging(string value);
    partial void OnDescriptionChanged();
    partial void OnTitleChanging(string value);
    partial void OnTitleChanged();
    partial void OnModeratorChanging(string value);
    partial void OnModeratorChanged();
    partial void OnDateTimeChanging(System.Nullable<System.DateTime> value);
    partial void OnDateTimeChanged();
    #endregion
	
	public SubForum()
	{
		this._Threads = new EntitySet<Thread>(new Action<Thread>(this.attach_Threads), new Action<Thread>(this.detach_Threads));
		OnCreated();
	}
	
	[Column(Storage="_SubForumID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	public int SubForumID
	{
		get
		{
			return this._SubForumID;
		}
		set
		{
			if ((this._SubForumID != value))
			{
				this.OnSubForumIDChanging(value);
				this.SendPropertyChanging();
				this._SubForumID = value;
				this.SendPropertyChanged("SubForumID");
				this.OnSubForumIDChanged();
			}
		}
	}
	
	[Column(Storage="_Description", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
	public string Description
	{
		get
		{
			return this._Description;
		}
		set
		{
			if ((this._Description != value))
			{
				this.OnDescriptionChanging(value);
				this.SendPropertyChanging();
				this._Description = value;
				this.SendPropertyChanged("Description");
				this.OnDescriptionChanged();
			}
		}
	}
	
	[Column(Storage="_Title", DbType="NVarChar(50)")]
	public string Title
	{
		get
		{
			return this._Title;
		}
		set
		{
			if ((this._Title != value))
			{
				this.OnTitleChanging(value);
				this.SendPropertyChanging();
				this._Title = value;
				this.SendPropertyChanged("Title");
				this.OnTitleChanged();
			}
		}
	}
	
	[Column(Storage="_Moderator", DbType="NVarChar(50)")]
	public string Moderator
	{
		get
		{
			return this._Moderator;
		}
		set
		{
			if ((this._Moderator != value))
			{
				this.OnModeratorChanging(value);
				this.SendPropertyChanging();
				this._Moderator = value;
				this.SendPropertyChanged("Moderator");
				this.OnModeratorChanged();
			}
		}
	}
	
	[Column(Storage="_DateTime", DbType="DateTime")]
	public System.Nullable<System.DateTime> DateTime
	{
		get
		{
			return this._DateTime;
		}
		set
		{
			if ((this._DateTime != value))
			{
				this.OnDateTimeChanging(value);
				this.SendPropertyChanging();
				this._DateTime = value;
				this.SendPropertyChanged("DateTime");
				this.OnDateTimeChanged();
			}
		}
	}
	
	[Association(Name="FK_Threads_SubForums", Storage="_Threads", ThisKey="SubForumID", OtherKey="_SubForumID", DeleteRule="NO ACTION")]
	public EntitySet<Thread> Threads
	{
		get
		{
			return this._Threads;
		}
		set
		{
			this._Threads.Assign(value);
		}
	}
	
	public event PropertyChangingEventHandler PropertyChanging;
	
	public event PropertyChangedEventHandler PropertyChanged;
	
	protected virtual void SendPropertyChanging()
	{
		if ((this.PropertyChanging != null))
		{
			this.PropertyChanging(this, emptyChangingEventArgs);
		}
	}
	
	protected virtual void SendPropertyChanged(String propertyName)
	{
		if ((this.PropertyChanged != null))
		{
			this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}
	}
	
	private void attach_Threads(Thread entity)
	{
		this.SendPropertyChanging();
		entity.SubForum = this;
	}
	
	private void detach_Threads(Thread entity)
	{
		this.SendPropertyChanging();
		entity.SubForum = null;
	}
}

[Table(Name="dbo.Threads")]
public partial class Thread : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private int _ThreadID;
	
	private string _Description;
	
	private System.Nullable<int> @__SubForumID;
	
	private string _Title;
	
	private string _Body;
	
	private string @__ClientID;
	
	private System.Nullable<System.DateTime> _DateTime;
	
	private EntitySet<Post> _Posts;
	
	private EntityRef<SubForum> _SubForum;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnThreadIDChanging(int value);
    partial void OnThreadIDChanged();
    partial void OnDescriptionChanging(string value);
    partial void OnDescriptionChanged();
    partial void On_SubForumIDChanging(System.Nullable<int> value);
    partial void On_SubForumIDChanged();
    partial void OnTitleChanging(string value);
    partial void OnTitleChanged();
    partial void OnBodyChanging(string value);
    partial void OnBodyChanged();
    partial void On_ClientIDChanging(string value);
    partial void On_ClientIDChanged();
    partial void OnDateTimeChanging(System.Nullable<System.DateTime> value);
    partial void OnDateTimeChanged();
    #endregion
	
	public Thread()
	{
		this._Posts = new EntitySet<Post>(new Action<Post>(this.attach_Posts), new Action<Post>(this.detach_Posts));
		this._SubForum = default(EntityRef<SubForum>);
		OnCreated();
	}
	
	[Column(Storage="_ThreadID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	public int ThreadID
	{
		get
		{
			return this._ThreadID;
		}
		set
		{
			if ((this._ThreadID != value))
			{
				this.OnThreadIDChanging(value);
				this.SendPropertyChanging();
				this._ThreadID = value;
				this.SendPropertyChanged("ThreadID");
				this.OnThreadIDChanged();
			}
		}
	}
	
	[Column(Storage="_Description", DbType="NChar(10)")]
	public string Description
	{
		get
		{
			return this._Description;
		}
		set
		{
			if ((this._Description != value))
			{
				this.OnDescriptionChanging(value);
				this.SendPropertyChanging();
				this._Description = value;
				this.SendPropertyChanged("Description");
				this.OnDescriptionChanged();
			}
		}
	}
	
	[Column(Storage="__SubForumID", DbType="Int")]
	public System.Nullable<int> _SubForumID
	{
		get
		{
			return this.@__SubForumID;
		}
		set
		{
			if ((this.@__SubForumID != value))
			{
				if (this._SubForum.HasLoadedOrAssignedValue)
				{
					throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
				}
				this.On_SubForumIDChanging(value);
				this.SendPropertyChanging();
				this.@__SubForumID = value;
				this.SendPropertyChanged("_SubForumID");
				this.On_SubForumIDChanged();
			}
		}
	}
	
	[Column(Storage="_Title", DbType="NVarChar(50)")]
	public string Title
	{
		get
		{
			return this._Title;
		}
		set
		{
			if ((this._Title != value))
			{
				this.OnTitleChanging(value);
				this.SendPropertyChanging();
				this._Title = value;
				this.SendPropertyChanged("Title");
				this.OnTitleChanged();
			}
		}
	}
	
	[Column(Storage="_Body", DbType="NVarChar(50)")]
	public string Body
	{
		get
		{
			return this._Body;
		}
		set
		{
			if ((this._Body != value))
			{
				this.OnBodyChanging(value);
				this.SendPropertyChanging();
				this._Body = value;
				this.SendPropertyChanged("Body");
				this.OnBodyChanged();
			}
		}
	}
	
	[Column(Storage="__ClientID", DbType="NVarChar(50)")]
	public string _ClientID
	{
		get
		{
			return this.@__ClientID;
		}
		set
		{
			if ((this.@__ClientID != value))
			{
				this.On_ClientIDChanging(value);
				this.SendPropertyChanging();
				this.@__ClientID = value;
				this.SendPropertyChanged("_ClientID");
				this.On_ClientIDChanged();
			}
		}
	}
	
	[Column(Storage="_DateTime", DbType="DateTime")]
	public System.Nullable<System.DateTime> DateTime
	{
		get
		{
			return this._DateTime;
		}
		set
		{
			if ((this._DateTime != value))
			{
				this.OnDateTimeChanging(value);
				this.SendPropertyChanging();
				this._DateTime = value;
				this.SendPropertyChanged("DateTime");
				this.OnDateTimeChanged();
			}
		}
	}
	
	[Association(Name="FK_Posts_Threads", Storage="_Posts", ThisKey="ThreadID", OtherKey="_ThreadID", DeleteRule="NO ACTION")]
	public EntitySet<Post> Posts
	{
		get
		{
			return this._Posts;
		}
		set
		{
			this._Posts.Assign(value);
		}
	}
	
	[Association(Name="FK_Threads_SubForums", Storage="_SubForum", ThisKey="_SubForumID", OtherKey="SubForumID", IsForeignKey=true)]
	public SubForum SubForum
	{
		get
		{
			return this._SubForum.Entity;
		}
		set
		{
			SubForum previousValue = this._SubForum.Entity;
			if (((previousValue != value) 
						|| (this._SubForum.HasLoadedOrAssignedValue == false)))
			{
				this.SendPropertyChanging();
				if ((previousValue != null))
				{
					this._SubForum.Entity = null;
					previousValue.Threads.Remove(this);
				}
				this._SubForum.Entity = value;
				if ((value != null))
				{
					value.Threads.Add(this);
					this.@__SubForumID = value.SubForumID;
				}
				else
				{
					this.@__SubForumID = default(Nullable<int>);
				}
				this.SendPropertyChanged("SubForum");
			}
		}
	}
	
	public event PropertyChangingEventHandler PropertyChanging;
	
	public event PropertyChangedEventHandler PropertyChanged;
	
	protected virtual void SendPropertyChanging()
	{
		if ((this.PropertyChanging != null))
		{
			this.PropertyChanging(this, emptyChangingEventArgs);
		}
	}
	
	protected virtual void SendPropertyChanged(String propertyName)
	{
		if ((this.PropertyChanged != null))
		{
			this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}
	}
	
	private void attach_Posts(Post entity)
	{
		this.SendPropertyChanging();
		entity.Thread = this;
	}
	
	private void detach_Posts(Post entity)
	{
		this.SendPropertyChanging();
		entity.Thread = null;
	}
}
#pragma warning restore 1591
